<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul></ul>
    <script>
        //创建结点
        var li_item = document.createElement('li');
        li_item.innerHTML = '创建结点';
        //获取元素
        var ul = document.querySelector('ul');
        // 添加结点；
        ul.appendChild(li_item);

        //创建第二个节点并添加
        var li_item2 = document.createElement('li');
        li_item2.innerHTML = '创建结点2';
        //把新创建的结点添加到最前面
        ul.insertBefore(li_item2, ul.children[0]);
    </script>
</body>
</html>